﻿using System;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKExcelFormTool.DataDefine;
using YJKExcelFormTool.Forms;

namespace YJKExcelFormTool
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdTestExcelMaterialTable : YJKCommandManual
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			MaterialProgramInfos._Tag_TemplateType templateType = MaterialProgramInfos._Tag_TemplateType.TT_EXCEL;
			TestMaterialInterfaceForm testMaterialInterfaceForm = new TestMaterialInterfaceForm(cmdData, templateType);
			if (testMaterialInterfaceForm.ShowDialog() != DialogResult.OK)
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			if (TableInterface.ExportMaterialTable(cmdData, testMaterialInterfaceForm.ProgramName(), testMaterialInterfaceForm.ProgramId(), testMaterialInterfaceForm.TheTableInfos, ref message) != null)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
